/*********************************************************************
	filename:	DaterServerSocket.h
	created:	9/4/2012
	author:		Michael Zhang
	
	purpose:	Defines concrete class for Dater server net work.
*********************************************************************/
#ifndef _DaterServerSocket_h_
#define _DaterServerSocket_h_

#include "DaterSocket.h"
#include "DaterServerSystem.h"

#include <map>
#include <string>

namespace Dater
{

	/*!
	\brief
		An entity class contains 21 year calendars front and back.
	*/
class DaterServerSocket : public DaterSocket
{
public:
		/*!
		\brief
			Constructor for ServerSocket class
		*/
	DaterServerSocket():_selectSocketSet(), _onlineClients() {}
		/*!
		\brief
			Destructor for CalendarData class
		*/
	~DaterServerSocket();
	
		/*!
		\brief
			a virtual function to init.
		*/
	virtual bool initialSocket();
	
		/*!
		\brief
			a function to init.
		*/
	bool bindSocket();
		/*!
		\brief
			a function to start listening.
		*/
	void startListen();
	
		/*!
		\brief
			a function to accept the socket.
		*/
	bool acceptSocket();
	
		/*!
		\brief
			a function to handle the request.
		*/
	bool handleRequest();
	
		/*!
		\brief
			a function to reset.
		*/
	void resetSelectSocketSet();

private:
	DaterServerSocket(const DaterServerSocket&);
	fd_set _selectSocketSet;
	std::map<int, SOCKET> _onlineClients;

	std::map<int, std::string> _clientRemainingBuffers;
};

}

#endif